<#import "/magicsoft/macro/standardLib.ftl" as std />

<#macro standardSelect searchItems leftColumns buttons extraParams rightColumns leftButtons rightButtons script showSearchMore=false rightTableWidth=420>
<div class="easyui-layout animated fadeIn" >   
    <div data-options="region:'north',border:false" style="max-height:400px;overflow:hidden;">
		<div class="datagrid-toolbar clearfix">
			<a href="#" class="linkbutton" id="btnOk_${model.clientId}">确定</a>
			${buttons}
		</div>
		<#if searchItems?? && searchItems != "">
			<@std.searchpanel id="searchPanel_${model.clientId}" showMore=showSearchMore>${searchItems}</@std.searchpanel>
		</#if>
    </div>
    
    <#--左侧table-->
	<div data-options="region:'center'">
		<div id="leftToolbar_${model.clientId}" class="std-select-table-text">
			<#if model.params.singleSelect[0]!='true'>
				<td style="padding-left:10px;">待选记录（您可以双击记录或点击<i class="fa fa-arrow-right"></i>，进行选择。）</td>
			<#else>
				<td style="padding-left:10px;">选择后，请单击确认按钮</td>	
			</#if>
			<#if leftButtons??>
				<div class="pull-left">
					${leftButtons}
				</div>
			</#if>
		</div>
		<table id="grid_${model.clientId}" class="magic-master-datagrid easyui-datagrid" data-options="fit:true,toolbar:'#leftToolbar_${model.clientId}',onLoadError:magicsoft.requestErrorHandler,url:'${model.viewPath}/records',method:'POST',queryParams:{parentPropertyPath:'${model.params.parentPropertyPath[0]}',parentId:'${model.params.parentId[0]}'<#if extraParams??>,${extraParams}</#if>}<#if model.params.singleSelect[0]=='true'>,singleSelect:true</#if>">
			 ${leftColumns}
		</table>
	</div>
	<#if model.params.singleSelect[0]!='true'>
	<div class="easyui-layout" data-options="region:'east',border:false" style="width:${rightTableWidth}px">
		<div data-options="region:'west',border:false" class="std-select-arrows">
			<a href="#" id="btnAllRight_${model.clientId}"><i class="fa fa-chevron-right"></i></a>
			<a href="#" id="btnRight_${model.clientId}"><i class="fa fa-arrow-right"></i></a>
			<a href="#" id="btnLeft_${model.clientId}"><i class="fa fa-arrow-left"></i></a>
			<a href="#" id="btnRightClear_${model.clientId}"><i class="fa fa-chevron-left"></i></a>
		</div>
		<#--右侧table-->
		<div data-options="region:'center'">
			<div id="rightToolbar_${model.clientId}" class="std-select-table-text">
				已选记录[<span id="rightTableCount_${model.clientId}">0</span>条]（您可以双击记录或点击<i class="fa fa-arrow-left"></i>，取消选择）</td>
				<#if rightButtons??>
					<div class="pull-right">
						${rightButtons}
					</div>
				</#if>
			</div>
			<table id="rightTable_${model.clientId}" class="easyui-datagrid" data-options="fit:true,pagination:false,toolbar:'#rightToolbar_${model.clientId}'">
				${rightColumns}
			</table>
		</div>
	</div>
	</#if>
</div>

<script>
$.parser.onComplete = function() {
	var options = {
		clientId: '${model.clientId}',
		singleSelect: '${model.params.singleSelect[0]}',
	};

	<#if script == null>
	magicsoft.standardSelect.initialize(options);
	</#if>
	
	${script}
	
	$.parser.onComplete = magicsoft.emptyFn;
};
</script>
</#macro>